<?php 

/** DAO de curso */
class DaoLaboratorio extends DAO {
	
	public function get($id) {
		$select = db_select(Laboratorio::TYPE)
		->fields(Laboratorio::TYPE)
		->condition('id', $id)
		->execute()
		->fetchAll();
		
		$lab = new Laboratorio();
		foreach($select as $row) {			
			$lab->id 					= $row->id;
			$lab->nome 				= $row->nome;
		}
		
		return $lab;
	}
	
	/** Carrega varias instancias do banco */
	public function listar() {
		$select = db_select(Laboratorio::TYPE)
								->fields(Laboratorio::TYPE)
									->execute()
										->fetchAll();
		
		$labs = array();
		foreach($select as $row) {
			$lab 							= new Laboratorio();
			$lab->id 					= $row->id;
			$lab->nome 				= $row->nome;
			
			array_push($labs, $lab);
		}
		
		return $labs;
	}
	
}

